<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<ul class="shortcut-buttons-set">
				<li>
					<a class="shortcut-button" href='#request_list'><span>
					<i class="aicon-task_list"></i>
					<?php echo $this->language['list'];?></span></a>
				</li>
				<li>
					<a class="shortcut-button" href='#request_list/status=0'><span>
					<i class="aicon-clock"></i>
					<?php echo $this->language['waiting'];?></span></a>
				</li>
				<li>
					<a class="shortcut-button" href='#request_create' ><span>
					<i class="aicon-plus"></i>
					<?php echo $this->language['request_create'];?></span></a>
				</li>
				<?php if(check_permission('request_view')): ?>
				<li>
					<a class="shortcut-button" href='#request_report'><span>
					<i class="aicon-chart"></i>
					Xem báo cáo</span></a>
				</li>
				<?php endif;?>
			</ul>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-file-text-alt"></i> Tạo phiếu hoàn ứng</div>
				</div>
				<div class="panel-body">
					<form action="javascript:createReturn();" class="form-horizontal" id="return-form">
						<div class="form-group">
							<label class="control-label col-lg-2"><?php echo $this->language['requests'];?></label>
							<div class="col-lg-10">
								<p class="form-control-static" style="padding-top:6px;"><a href="#request_view/id=<?php echo $this->request['req_id'];?>"><?php echo $this->request['req_reason'];?></a></p>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-lg-2">Số tiền tạm ứng</label>
							<div class="col-lg-3">
								<div class="input-group">
									<input class="form-control" value="<?php echo number_format($this->request['amount'],0,'.',',');?>" disabled />
									<span class="input-group-addon">VNĐ</span>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-lg-2"><?php echo $this->language['amount_money'];?></label>
							<div class="col-lg-3">
								<div class="input-group">
									<input class="form-control" id="bangso" value="0" disabled />
									<span class="input-group-addon">VNĐ</span>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-lg-2"><?php echo $this->language['amount_money_text'];?></label>
							<div class="col-lg-10">
								<input class="form-control" id="bangchu" disabled />
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-lg-2"><?php echo $this->language['detail'];?></label>
							<div class="col-lg-10">
								<table class="table table-hover table-condensed" id="dbdetail">
									<thead>
										<tr>
											<th><?php echo $this->language['name'];?></th>
											<th width="70px"><?php echo $this->language['unit'];?></th>
											<th width="90px"><?php echo $this->language['amount'];?></th>
											<th width="120px"><?php echo $this->language['price'];?></th>
											<th width="140px"><?php echo $this->language['amount_money'];?></th>
											<th width="40px"></th>
										</tr>
									</thead>
									<tbody></tbody>
									<tfoot>
										<tr>
											<td colspan=6><a data-toggle="modal" href="#additem"><img src="resources/images/icons/pencil.png" /> Thêm</a></td>
										</tr>
									</tfoot>
								</table>
							</div>
						</div>
						<div class="form-group">
							<div class="col-lg-offset-2 col-lg-10">
								<input type="hidden" name="request" value="<?php echo $this->request['req_id'];?>">
								<input type="hidden" id="dtdb" name="dtdb">
								<input type="hidden" id="total" name="total" value="0">
								<button class="btn btn-primary" type="submit"><?php echo $this->language['accept'];?></button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="additem">
		<div class="modal-dialog">
			<div class="modal-content">
				<form action="javascript:createItem();" class="form-horizontal">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title"><?php echo $this->language['add_new'];?></h4>
					</div>
					<div class="modal-body">
						<fieldset>
							<div class="form-group">
								<label class="control-label col-lg-2"><?php echo $this->language['name'];?></label>
								<div class="col-lg-10">
									<input type="text" class="form-control" id="name" placeholder="Nhập tên" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-lg-2"><?php echo $this->language['unit'];?></label>
								<div class="col-lg-10">
									<input type="text" class="form-control" id="donvi" placeholder="(Ngày/Cái/Thùng)" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-lg-2"><?php echo $this->language['price'];?></label>
								<div class="col-lg-10">
									<input type="text" class="form-control" id="dongia" placeholder="Đơn giá" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-lg-2"><?php echo $this->language['amount'];?></label>
								<div class="col-lg-10">
									<input type="text" class="form-control" id="soluong" placeholder="0" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-lg-2"><?php echo $this->language['description'];?></label>
								<div class="col-lg-10">
									<textarea class="form-control" rows="3" id="mota"></textarea>
								</div>
							</div>
						</fieldset>
					</div>
					<div class="modal-footer">
						<input type="submit" class="btn btn-primary" value="<?php echo $this->language['accept'];?>" />
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="resources/scripts/jquery-ui.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#dongia").change(function(){
				var money = $("#dongia").val();
				$("#dongia").val(toCurrency(money.replace(/,/g,"")));
			});
		});
	</script>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>